//
//  MeInfoCell.m
//  YSSmartHome
//
//  Created by yanghao on 25/05/2017.
//  Copyright © 2017 yahaong. All rights reserved.
//

#import "MeInfoCell.h"
#import "YSCommon.h"

@interface MeInfoCell ()
@property (nullable, nonatomic, strong) UIView* splitLine;
@end

@implementation MeInfoCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ( self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initSubviews];
    }
    return self;
}

#pragma mark - private method 

- (void)initSubviews {
    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.rightButton];
    [self.contentView addSubview:self.splitLine];
    [self layoutPageSubviews];
}

- (void)layoutPageSubviews {
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.contentView);
        make.leading.equalTo(self.contentView).offset(10);
    }];

    [self.rightButton makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.trailing.equalTo(self.contentView.trailing);
//        make.width.equalTo(20);
//        make.height.equalTo(20);
    }];
    [self.splitLine makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.bottom.equalTo(self.contentView);
        make.height.equalTo(1);
    }];
}
#pragma mark - getters and settters

- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = [UIFont systemFontOfSize:14];
    }
    return _titleLabel;
}

- (UIButton *)rightButton {
    if (!_rightButton) {
        _rightButton = [[UIButton alloc]init];
        _rightButton.titleLabel.font = [UIFont systemFontOfSize:13];
        [_rightButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }
    return _rightButton;
}

- (UIView *)splitLine
{
    if (!_splitLine) {
        _splitLine = [[UIView alloc]init];
        _splitLine.backgroundColor = kBgColor;
    }
    return _splitLine;
}

@end
